/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package swing.mutilCheckBox;

import java.awt.Component;
import java.awt.Font;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author Administrator
 */
public class CheckBoxListCellRenderer extends JCheckBox implements
		ListCellRenderer {
	private JComboBox	comboBox	= null;

	public CheckBoxListCellRenderer(JComboBox comboBox) {
		this.comboBox = comboBox;
		this.comboBox.setEditable(true);
	}

	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		setEnabled(true);
		if (value != null) {
			if (value instanceof LEnterpriseCurrSituation) {
				final LEnterpriseCurrSituation item = (LEnterpriseCurrSituation) value;
				setSelected(item.getIsSelected());
				this.setText(item.getName());
			}else{
                            this.setText(value.toString());
                        }
		}
		if (isSelected) {
			this.setForeground(list.getSelectionForeground());
			this.setBackground(list.getSelectionBackground());
			this.setFont(new Font(null, Font.BOLD, 12));
		} else {
			this.setForeground(list.getForeground());
			this.setBackground(list.getBackground());
			this.setFont(list.getFont());
		}
		return this;
	}
}
